﻿using LanzhouBeefNoodles.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace LanzhouBeefNoodles.Data
{
    public class NoodleData : INoodle
    {
        private readonly AppDbContext _db;
        public NoodleData(AppDbContext appDbContext)
        {
            _db = appDbContext;
        }

        public IEnumerable<Noodle> GetAllNoodles() //返回数据库中所有得面条
        {
            return _db.Noodles;
        }

        public Noodle GetNoodleById(int id)
        {
            return _db.Noodles.FirstOrDefault(n => n.Id == id);
        }
    }
}
